# function get1(){
#     num1=$1
#     if [ $1 -eq 1 ]
#     then
#         date
#     elif [ $1 -eq 2 ]
#     then
#         ifconfig
#     elif [ $1 -eq 3 ]
#     then
#         echo "$USER"
#     elif [ $1 -eq 4 ]
#     then
#         ls -l | grep "^-"
#     else
#         return 1 #输入非数字1-4时退出循环
#     fi
# }
# read -p "请输入想要执行的命令:" mingling
# get1 $mingling

# # 数据清洗部分
# sed 's/\[{//g' /root/shell/movie.txt \
# | sed 's/}, {/\n/g' \
# | sed "s/'//g" \
# | sed 's/ //g' \
# | awk -v FS="," -v OFS="," '{print $4,$5,$7,$10}' \
# | sed 's/id://g' \
# | sed 's/title://g' \
# | sed 's/release_date://g' \
# | sed 's/score://g' \
# | awk -v FS="," -v OFS="," 'BEGIN{print "id,title,release_date,score"} \
# {print $1,$2,$3,$4}' > /root/shell/movie.csv

# # 导入数据库部分
#  host="127.0.0.1"
#  port=3306
#  user="root"
#  passwd="root123456"
#  dbname="test"

# # 建表前先删表
#  sql1="drop table if exists $1" 
# mysql -h$host -P$port -u$user -p$passwd $dbname -e "$sql1"

# # 确定没有同名的表后建表
# # 首先获取第一行
# names=`head -n +1 /root/shell/movie.csv | sed 's/,/ /g'`
# # 找出最后一个列名
# lastname=`echo "$names" | awk '{print $NF}'`
# sql2="create table if not exists $1("
#     for i in $names
#     do
#         if [ $i == "$lastname" ]
#         then
#             sql2="$sql2$i varchar(200))"
#         else
#             sql2="$sql2$i varchar(200),"
#         fi
#     done

# mysql -h$host -P$port -u$user -p$passwd $dbname -e "$sql2"

# # 导入数据
# sql3="LOAD DATA INFILE '$2' INTO TABLE $1
# CHARACTER SET utf8
# FIELDS TERMINATED BY ','
# LINES TERMINATED BY '\n'
# IGNORE 1 LINES"
# mysql -h$host -P$port -u$user -p$passwd $dbname -e "$sql3"

# # 查看表和数据
# sql4="select * from $1"
# mysql -h$host -P$port -u$user -p$passwd $dbname -e "$sql4"

# printf "关羽\n张飞\n大乔\n刘备\n谷爱凌\n曹操\n夏侯淳\n小乔\n李典\n周瑜\n孙坚\n" >> /root/shell/kaoshimingzi.txt
# function getName(){
#     str="关羽,张飞,大乔,刘备,谷爱凌,曹操,夏侯淳,小乔,李典,周瑜,孙坚"
#     ln=0
#     gj=0
#     lz=0

#     names=(${str//,/ })

# for i in ${names[@]}
#     do
#         if [ $i == "大乔" ] || [ $i == "小乔" ]
#         then
#             echo "$i 靓女"
#             ln=$((ln+1))
#         elif [ $i == "谷爱凌" ]
#         then
#             echo "$i 冠军"
#             gj=$((gj+1))
#         else
#             echo "$i 靓仔"
#             lz=$((lz+1))
#         fi
#     done
#     echo "靓女有$ln个,冠军有$gj个,靓仔有$lz个"
# }
# read -p "请按回车进入循环"
# getName 




# function getName(){
#     s=`echo $1 | sed 's/,/ /g'`
#     echo $s
#     ln=0
#     gj=0
#     lz=0
# for i in $s
#     do
#         if [ $i == "大乔" -o $i == "小乔" ]
#         then
#             ln=$(($ln+1))
#             echo "$i 靓女"
#         elif [ $i == "谷爱凌" ]
#         then
#             gj=$(($gj+1))
#             echo "$i 冠军"
#         else
#             lz=$(($lz+1))
#             echo "$i 靓仔"
#         fi
#     done
#     echo "靓女有$ln个,冠军有$gj个,靓仔有$lz个"
# }
# str="关羽,张飞,大乔,刘备,谷爱凌,曹操,夏侯淳,小乔,李典,周瑜,孙坚"
# getName $str

# sed 's/，/,/g' /root/shell/student.txt \
# | awk -v FS="," -v OFS="," '{print $1,$2,$3,$4,$5}' /root/shell/student.txt > /root/shell/student.csv
# sed -i 1d /root/shell/student.csv
# function getRank(){
#     score=`awk -v FS='，' -v OFS=',' '{print $NF}' /root/shell/student.csv`
#     A=0
#     B=0
#     C=0
#     D=0
#     F=0
#     for i in $score
#         do
#             if [ $i -gt 90 ]
#             then
#                 A=$((A+1))
#             elif [ $i -gt 80 ]
#             then
#                 B=$((B+1))
#             elif [ $i -gt 70 ]
#             then
#                 C=$((C+1))
#             elif [ $i -gt 60 ]
#             then
#                 D=$((D+1))
#             elif [ $i -gt 100 ] || [ $i -lt 0 ]
#             then
#                 echo "数据出错！请检查数据！"
#             else
#                 F=$((F+1))
#             fi
#         done
#     echo "A等:$A人"
#     echo "B等:$B人"
#     echo "C等:$C人"
#     echo "D等:$D人"
#     echo "F等:$F人"
# }
# getRank



